package com.softsec.isc.analysis;
import java.io.DataInputStream;
import java.io.IOException;


public class Uleb128 {
	public static int readLeb128(DataInputStream input) throws IOException{
		int result=0; int cur=0;
		result=input.read();
		if(result>0x7f){
			cur=input.read();
			result=(result& 0x7f)|((cur&0x7f)<<7);
			if(cur>0x7f){
				cur=input.read();
				result|=(cur&0x7f)<<14;
			//	result=result|((cur&0x7f)<<14);
				if(cur>0x7f){
					cur=input.read();
					result|=(cur&0x7f)<<21;
					if(cur>0x7f){
						cur=input.read();
						result|=cur<<28;
					}
				}
				
			}
			
		}
		
		return result;
		
	}
	
	
//	public static void main(String[] args) throws IOException  {
//		String fileName="d:/Hello.dex";
//		File file = new File(fileName);
//		 FileInputStream input1=new FileInputStream(file);
//		 DataInputStream input=new DataInputStream(input1);
//		 input.skip(635);
//		 int[] result=new int[4];
//		// int cur=0;
//		 for(int i=0;i<4;i++){
//			 result[i]=readLeb128(input);
//		 }
//		 for(int j=0;j<4;j++){
//		 System.out.println("result: "+result[j]);
//		 }
//	}
	

}
